/*
 create by sys on 2016/11/22.
 */

define(["require",'config/appregister',"business/Companyinfor/service/htttp","business/services/constant",
    "business/services/filter","jquery","business/workSkill/directive/startLevel", "business/services/evaluateComp",
    "business/services/components"],function(require,app,httpServices,constant,$stateParams){
    app.controller('evaceCtrl',function($scope,$timeout,auth){
        auth.isCompanyLogin();
        //企业点评
        //评论配置
        $scope.bgColor=1;
        function companyInfo2(){
            var req ={
                type:"GET",
                uri:"getBaseInfoByUser",
                data:{}
            };
            httpServices.homePageHttpService(req).success(function(result){
                $scope.$apply(function(){
                    $scope.companyInfo = result.data;
                    $scope.compayId = result.data.companyId;
                    getEva2()
                    $scope.commentConf = {
                        showStar:true,
                        url:constant.config.BASEURL_BLOG,
                        base:"elink_user/api/comment",
                        conf:{
                            id:$scope.compayId,
                            type:1,
                            fkId:$scope.compayId
                        },
                        uri:{
                            getTopComment:"getTopCommentsByFileId"  ,
                            getSecComment:"getAllCommentsByTopId",
                            publish:"add",
                            reply:"addReply",
                            praise:"addPraise",
                            evaluate:"getEvaluateById",
                            recentComment:"getRecentComment"
                        }
                    };


                    $scope.evaSc = Math.ceil(result.data.totalScore/result.data.commentCount)
                })
            });
        }
        companyInfo2();




        /*点评管理*/
        $scope.max = 5;//最大星级
        $scope.ratingVal = 3;///默认星级，必需设置，下面同样名字覆盖，否则不显示；
        $scope.readonly = true;//false可编辑，true不可编辑
        $scope.onHover = function(val){
            $scope.hoverVal = val;
        };
        $scope.onLeave = function(){
            $scope.hoverVal = null;
        }
        $scope.onChange = function(val){
            $scope.ratingVal = val;
        };
        /*进度条1*/

        /*星级end*/
        function getEva2(){
                var req ={//默认全部内容
                    type:"GET",
                    uri:"getEvaluateById",
                    data:{
                        fkId:$scope.compayId,
                        type:1
                    }
                };
                httpServices.getComPanyEva(req).success(function(response){
                    $scope.$apply(function(){
                        $scope.CompanyEva = response.data;
                        if(response.data.count!=0){
                            $scope.ratingVal = Math.floor(response.data.totalStar/response.data.count);
                            $scope.value5=100
                                -Math.ceil(response.data.fourStar/response.data.count*100)
                                -Math.ceil(response.data.threeStar/response.data.count*100)
                                -Math.ceil(response.data.twoStar/response.data.count*100)
                                -Math.ceil(response.data.oneStar / response.data.count *100);
                            $scope.value4=Math.ceil(response.data.fourStar/response.data.count*100);
                            $scope.value3=Math.ceil(response.data.threeStar/response.data.count*100);
                            $scope.value2=Math.ceil(response.data.twoStar/response.data.count*100);
                            $scope.value1=Math.ceil(response.data.oneStar / response.data.count *100);
                        }else{
                            $scope.ratingVal=$scope.value4=$scope.value3=$scope.value2=$scope.value1=$scope.value5=0;
                        }

                    })
                });
            }




    })
});
